#ifndef GAMEENGINE_CORE_GRAPH_LINK_H
#define GAMEENGINE_CORE_GRAPH_LINK_H

#include <GameEngine/Core/core_settings.h>

#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

//! Class in charge of representing a graph link
/*!
 *  A graph link represent the adjacency between
 *  two nodes. It can additionally store a value
 *  of type T, which can e.g. be the travel time
 *  from the first to the second node.
 */
template <class N, class T>
class GraphLink {

public:
	//! Typedef to handle constant node pointers
	typedef const N* N_pointer;

public:
	GraphLink(N_pointer node1 = nil, N_pointer node2 = nil);
	GraphLink(const T& value, N_pointer node1 = nil, N_pointer node2 = nil);
	GraphLink(const GraphLink& rhs);
	~GraphLink();
	GraphLink& operator=(const GraphLink& rhs);

	bool operator<(const GraphLink& rhs) const;

	T& value();
	const T& value() const;

	bool contains(const N_pointer node) const;
	N_pointer get_neighbour(const N_pointer node) const;

	N_pointer node1() const;
	N_pointer& node1();
	N_pointer node2() const;
	N_pointer& node2();

protected:
	//! Value associated to the link
	T value_;

	//! First node pointed by the link
	N_pointer node1_;
	//! Second node pointed by the link
	N_pointer node2_;
};

#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#include <GameEngine/Core/Graph/graph_link.hpp>

#endif
